package com.laoniu.controller.goods;

import com.laoniu.annotation.OperateLog;
import com.laoniu.biz.goods.GoodsSaleBiz;
import com.laoniu.dto.RestResult;
import com.laoniu.dto.request.GoodsStockRequestDto;
import com.laoniu.dto.response.GoodsSaleDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 商品销售表 前端控制器
 * </p>
 *
 * @author lxl
 * @since 2023-12-17
 */
@RestController
@RequestMapping("/goods/sale")
public class GoodsSaleController {

    @Autowired
    private GoodsSaleBiz saleBiz;
    /**
     * 商品销售列表
     * @param requestDto
     * @return
     */
    @PostMapping("list")
    public RestResult list(@RequestBody GoodsStockRequestDto requestDto){
        return RestResult.success(saleBiz.pageList(requestDto));
    }

    /**
     * 商品销售
     * @param dto
     * @return
     */
    @PostMapping("add")
    @OperateLog(bizName = "商品销售", operateType = "商品销售", operateDesc = "新增商品销售")
    public RestResult add(@RequestBody GoodsSaleDto dto){
        saleBiz.goodsSale(dto);
        return RestResult.success();
    }
}
